fix: terminal scroll preservation on tab switch and alt buffer exit#2858
Draft
JustHereToHelp wants to merge 1 commit intowavetermdev:mainfrom
Draft
fix: terminal scroll preservation on tab switch and alt buffer exit#2858JustHereToHelp wants to merge 1 commit intowavetermdev:mainfrom
JustHereToHelp wants to merge 1 commit intowavetermdev:mainfrom
Conversation
Two related scroll-to-top bugs: Tab switch: switching tabs triggered intermediate repositioning that caused xterm.js buffer reflow and scroll loss. Fix: skip intermediate positioning for already-initialized tabs via skipIntermediate flag. Alt buffer exit: exiting htop/vim/less reset scroll to top. Fix: save baseY before alt buffer exit in OSC 16162 "R" handler, restore via onBufferChange + requestAnimationFrame. Also guards handleResize to only restore scroll when dimensions actually changed. Fixes wavetermdev#2384, fixes wavetermdev#2790
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2384, fixes #2790
Two related scroll-to-top bugs that have been driving me crazy:
Tab switch scroll jump: Switching between tabs would reset the terminal scroll position to the top. The issue was that intermediate tab repositioning during the switch triggered resize events that reset the viewport. Fix: skip intermediate tab repositioning for already-initialized tabs in
emain-window.ts, and guardhandleResizeto only restore scroll if dimensions actually changed.Alt buffer exit scroll jump: Exiting a full-screen program (htop, vim, less, etc.) would scroll the terminal to the top. Fix: save the
baseYscroll position via xterm.jsonBufferChange, then restore it withrequestAnimationFrameafter the buffer switch completes. Also added an auto-scroll guard so it doesn't interfere if the user was already at the bottom.Heads up — this fixes it in most cases but I've still seen occasional jumps in edge cases. Probably needs a couple more trigger points caught, but it's way better than before.
Test plan
htoporless /etc/hosts, scroll around, quit — terminal should not jump to topvim, edit something, quit — scroll should hold